package cn.lijiguo.concurrency.part1.ch06;

/**
 * ThreadInterrupt
 *
 * @author lijiguo
 * @date 2019/12/13 13:47
 */
public class ThreadInterrupt {

    public static void main(String[] args) {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                while(true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        System.out.println("收到打断信号");
                        e.printStackTrace();
                    }
                }
            }
        };

        t1.start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(t1.isInterrupted());
        t1.interrupt();
        System.out.println(t1.isInterrupted());
    }
}
